import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    goods:[],
    getgoods:[]
  },
  mutations: {
    setlist(state,val){
      state.goods = val
      state.getgoods = val
    },
    dian(state,id){
     this.getgoods=state.goods.filter((item)=>{
        return item.tab=id
      })
    }
  },
  actions: {
    getgoods(context){
      axios.get("list.json").then((res)=>{
        console.log(res);
        context.commit("setlist",res.data.data)
      })
    }
  },
  modules: {
  }
})
